package com.yjk.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yjk.entity.User;
import com.yjk.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yjk
 * @since 2022-03-15
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private IUserService us;

    @GetMapping("/")
    public List<User> selectAll(){
        return us.list();
    }

    @GetMapping("/login")
    public boolean login(String idcard,String pwd){
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        //根据获取的账号密码查询用户并返回对象
        wrapper.eq("idcard",idcard).eq("pwd",pwd);
        Object one = us.getOne(wrapper);
        return one!=null;
    }


}

